# -*- coding: utf-8 -*-
from django.db.models import permalink, signals
from google.appengine.ext import db
from ragendja.dbutils import cleanup_relations

class Site(db.Model):
    """Basic user profile with personal details."""
    Site_name = db.StringProperty(required=True)
    Site_Url = db.StringProperty(required=True)

    def __unicode__(self):
        return '%s   %s' % (self.Site_name, self.Site_Url)

    @permalink
    def get_absolute_url(self):
        return ('feed.views.show_person', (), {'key': self.key()})

signals.pre_delete.connect(cleanup_relations, sender=Site)

class Article(db.Model):
    writer = db.ReferenceProperty(Site, required=True, collection_name='file_set')
    title = db.StringProperty(required=True)
    content1 = db.StringProperty(required=True)
    #file = db.BlobProperty(required=True)

    @permalink
    def get_absolute_url(self):
        return ('myapp.views.download_file', (), {'key': self.key(),
                                                  'name': self.name})

    def __unicode__(self):
        return u'File: %s' % self.name

#class Contract(db.Model):
#    employer = db.ReferenceProperty(Person, required=True, collection_name='employee_contract_set')
#    employee = db.ReferenceProperty(Person, required=True, collection_name='employer_contract_set')
#    start_date = db.DateTimeProperty()
#    end_date = db.DateTimeProperty()
